package edu.hbsi.demo2;

public class MyPan {
}
class MyPen extends Pen {
    private String brand;
    private int weight;

    // 默认形式构造函数
    public MyPen() {
        super(); // 调用父类的默认构造函数
        this.brand = "Generic";
        this.weight = 10;
    }

    // 有两个参数color和weight的构造函数
    public MyPen(String color, int weight) {
        super(color); // 调用父类只有一个String参数的构造函数
        this.brand = "Generic";
        this.weight = weight;
    }

    // 有两个参数length和weight的构造方法
    public MyPen(int length, int weight) {
        super(length); // 调用父类只有一个int参数的构造函数
        this.brand = "Generic";
        this.weight = weight;
    }

    // 有三个参数color、length和weight的构造函数
    public MyPen(String color, int length, int weight) {
        super(color, length); // 调用父类有两个参数的构造函数
        this.brand = "Generic";
        this.weight = weight;
    }

    // weight的访问方法
    public int getWeight() {
        return weight;
    }

    // 重写父类的display()方法
    @Override
    public void display() {
        super.display();
        System.out.println("Brand: " + brand + ", Weight: " + weight);
    }

    // 实现父类的抽象方法draw()
    @Override
    void draw() {
        System.out.println("绘画");
    }
}
